package io.github.talelin.sleeve.controller.v1;

import io.github.talelin.sleeve.module.message.WsHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("test")
public class WebSocketController {
    @Autowired
    private WsHandler wsHandler;

    @PostMapping("/wsc")
    public String index() {
        try {
            wsHandler.broadCast("广播一条消息");
        } catch (IOException e) {
            e.printStackTrace();
        }
        // 省略其它代码
        return "wc";
    }

}
